
    /**  
    * @Title: PrintClientUtil.java
    * @Package com.efast.cafe.util
    * @Description: TODO(用一句话描述该文件做什么)
    * @author Administrator
    * @date 2018年11月28日
    * @version V1.0  
    */
    
package com.efast.cafe.util;

import java.io.File;
import java.io.FileInputStream;

import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPClientConfig;

import com.efast.cafe.framework.exception.ServiceException;

    /**
    * @ClassName: PrintClientUtil
    * @Description: TODO(这里用一句话描述这个类的作用)
    * @author Administrator
    * @date 2018年11月28日
    *
    */

public class PrintClientUtil {

	FTPClient client = new FTPClient();
	
	String host;
	String user;
	String pass;
	String path;
	String filename;
	FileInputStream fis = null;
	
	public boolean sendLayoutToPrinter(String filename)throws Exception{
		boolean result = false;
		host = "";
		try 
		{	
			
			client.connect(host);
			client.login(user, pass);
			fis = new FileInputStream(filename);	
			client.enterLocalPassiveMode();
			result = client.storeFile(filename, fis);														
			fis.close();
			client.logout();
			
		}catch(Exception e){
			throw new ServiceException("FTPClient: Error: The printer  "+host+" "+ e.getMessage());
		}
		return result;
	}
	
	
	
}
